<?php
class C_pembelian extends CI_Controller {
	function __construct(){
		parent::__construct();
		$this->load->model('m_pembelian');
	}
	function index(){
		$task = $this->input->post('task');
		switch($task){
			case 'LIST' :
				$this->getlist();
				break;
			case 'SAVE' :
				$this->save();
				break;
			case 'PRINT' :
				$this->cetak();
				break;
			default :
				$this->load->view('v_pembelian');
		}
	}	
	function save(){
		$data = array(
			'kwitansi_date' => $this->input->post('kwitansi_date'),
			't_pengajuandet_id' => $this->input->post('t_pengajuandet_id'),
			'kwitansi_dari' => $this->input->post('kwitansi_dari'),
			'kwitansi_value' => $this->input->post('kwitansi_value'),
			'kwitansi_ket' => $this->input->post('kwitansi_ket')
		);
		echo $this->m_kwitansi->save($data);

	}
	
	function cetak(){
		$data = array (
			'kwitansi_tanggal' => $this->input->post('kwitansi_date'),
			'kwitansi_nomor_bukti' => $this->input->post('kwitansi_no'),
			'kwitansi_pro_keg' => $this->input->post('prog_keg'),
			'kwitansi_akun' => $this->input->post('akun'),
			'kwitansi_jumlah_uang' => $this->input->post('jumlah'),
			'kwitansi_terbilang_field' => $this->input->post('terbilang'),
			'kwitansi_pembayaran' =>$this->input->post('untuk')
		);
		$html  = $this->load->view('v_nota_kwitansi',$data,true);
		$file = fopen('report/print/kwitansi.html','w+');
		fwrite($file,$html);
	}
	
}